class RestaurentController < ApplicationController
  def index
    @base_dishes = BaseDish.find(:all)
  end

  def buy
    #Skill .create
    base_dish = BaseDish.find(params[:id])
    dish_skill = DishSkill.find_or_create_by_user_id_and_base_dish_id(@user.id, params[:id])
    dish_skill.ep ||=0
    dish_skill.ep += 50
    dish_skill.save!

    #TODO: Decrease user's money

    flash[:notice] = "购买成功, 你已经学会做 #{base_dish.name} 了"
    redirect_to :action => 'index'
  end
end
